import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
//定义token过期事件
const tiemKey = 'expireTime'
// 获取token
export function getToken() {
  return Cookies.get(TokenKey)
}
// 设置token
export function setToken(token) {
  return Cookies.set(TokenKey, token)
}
//删除token
export function removeToken() {
  return Cookies.remove(TokenKey)
}
//清空缓存
export function clearStorage(){
  return sessionStorage.clear()
}

/**设置token过期时间
 * @returns 
 */
export function setTokenTime(time){
  return sessionStorage.setItem(tiemKey,time)
}

/**获取token过期时间
 * @returns 
 */
export function getTokenTime(){
  return sessionStorage.getItem(tiemKey)
}

/**清空token过期时间
 * @returns 
 */
export function removeTokenTime(){
  return sessionStorage.removeItem(tiemKey,0)
}